﻿<%@ Page Title="Manage Orders" Language="C#" MasterPageFile="~/AdminPages/AdminPanel.Master" AutoEventWireup="true" CodeBehind="ManageOrders.aspx.cs" Inherits="MasterPageGroupF3.AdminPages.WebForm3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="content1">
        <div class="frame">
            <div class="head">

            </div>
            <div class="content-catalog">
                <div id="name-member">
                    Manage Orders
                </div>
                <div id="function">
                    <ul>
                        <%-- <li><asp:ImageButton ID="Edit" runat="server" ImageUrl="../images/edit.png" 
                                ToolTip="Edit" ImageAlign="Middle" OnClick="Edit_Click" AlternateText="Edit"/></li>
                        <li><asp:ImageButton ID="Delete" runat="server" ImageUrl="../images/delete.png" 
                                ToolTip="Delete" ImageAlign="Middle" OnClick="Delete_Click" 
                                AlternateText="Delete"/></li>
                        <li><asp:ImageButton ID="Help" runat="server" ImageUrl="../images/help.png" 
                                ToolTip="Help" ImageAlign="Middle" OnClick="Help_Click" AlternateText="Help"/></li> --%>      
                    </ul>
                
                </div>
                <div class="clear">
                </div>
            </div>
            <div class="tail">
            </div>
        </div>
        <div class="frame">
            <div class="head">
            </div>
            <div class="provider">
           
                <div id="search">
                    <strong>
                    <span style="color: red">
                    <span style="text-decoration: underline; font-size: large">
                    Note: 
                    Status có các giá trị và ý nghĩa sau</span><br 
                        style="text-decoration: underline; font-size: large" />
                    </span>0: Khách hàng đăng ký mua <br />
                    1: Đang giao phiếu khuyến mãi <br />
                    2: Hoàn tất giao phiếu <br />
                    3: Hoàn tiền cho khách hàng <br />
                        
                    <br />

                    <asp:Label ID="Label1" runat="server" Text="Filter by Status :" style="font-size: large"></asp:Label>                        
                    &nbsp;
                    <asp:DropDownList ID="FilterByStatus" runat="server" AutoPostBack="True" 
                        onselectedindexchanged="FilterByStatus_SelectedIndexChanged">
                        <asp:ListItem Value="0">Đăng ký mua</asp:ListItem>
                        <asp:ListItem Value="1">Đang giao phiếu</asp:ListItem>
                        <asp:ListItem Value="2">Hoàn tất giao dịch</asp:ListItem>
                        <asp:ListItem Value="3">Hoàn tiền</asp:ListItem>
                    </asp:DropDownList>
                    <br />

                    <asp:Label ID="Label2" runat="server" Text="Filter by Product :" 
                        style="font-size: large; font-weight: 700;"></asp:Label>                        
                    &nbsp;<asp:DropDownList ID="FilterByProduct" runat="server" AutoPostBack="True" 
                        DataSourceID="SqlDataSourceFilterByProduct" DataTextField="IDPRODUCT" 
                        DataValueField="IDPRODUCT" 
                        onselectedindexchanged="FilterByProduct_SelectedIndexChanged">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSourceFilterByProduct" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:NHOMMUAConnectionString %>" 
                        SelectCommand="SELECT DISTINCT [IDPRODUCT] FROM [ORDERS]">
                    </asp:SqlDataSource>

                    </strong>

                </div>
                <div id="listprovider">
                    <asp:GridView ID="GridViewFilterByStatus" runat="server" AllowPaging="True" 
                        AllowSorting="True" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" 
                        BorderWidth="1px" CellPadding="4" 
                        DataKeyNames="IDMEMBER,IDPRODUCT" 
                        ForeColor="Black" GridLines="Vertical" AutoGenerateColumns="False" 
                        DataSourceID="LinqDataSourceOrdersByStatus">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:TemplateField HeaderText="Username" SortExpression="MEMBER.USERNAME">
                                <ItemTemplate>
                                    <%#Eval("MEMBER.USERNAME")%>
                                </ItemTemplate>
                            </asp:TemplateField>                                
                            <asp:BoundField DataField="IDPRODUCT" HeaderText="IDPRODUCT" 
                                SortExpression="IDPRODUCT" ReadOnly="True" />
                            <asp:BoundField DataField="PRICE" HeaderText="PRICE" 
                                SortExpression="PRICE" ReadOnly="True" />
                            <asp:BoundField DataField="QUANTITY" HeaderText="QUANTITY" 
                                SortExpression="QUANTITY" />
                            <asp:BoundField DataField="STATUS" HeaderText="STATUS" 
                                SortExpression="STATUS" />
                            <asp:BoundField DataField="TIME" HeaderText="TIME" SortExpression="TIME" />
                            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                        </Columns>
                        <FooterStyle BackColor="#CCCC99" />
                        <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                        <RowStyle BackColor="#F7F7DE" />
                        <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                        <SortedAscendingCellStyle BackColor="#FBFBF2" />
                        <SortedAscendingHeaderStyle BackColor="#848384" />
                        <SortedDescendingCellStyle BackColor="#EAEAD3" />
                        <SortedDescendingHeaderStyle BackColor="#575357" />
                    </asp:GridView>     
                        
                    <asp:GridView ID="GridViewFilterByProduct" runat="server" AllowPaging="True" 
                        AllowSorting="True" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" 
                        BorderWidth="1px" CellPadding="4"
                        DataKeyNames="IDMEMBER,IDPRODUCT" 
                        ForeColor="Black" GridLines="Vertical" AutoGenerateColumns="False" 
                        DataSourceID="LinqDataSourceOrdersByProduct">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:TemplateField HeaderText="Username" SortExpression="MEMBER.USERNAME">
                                <ItemTemplate>
                                    <%#Eval("MEMBER.USERNAME")%>
                                </ItemTemplate>
                            </asp:TemplateField>                                
                            <asp:BoundField DataField="IDPRODUCT" HeaderText="IDPRODUCT" 
                                SortExpression="IDPRODUCT" />
                            <asp:BoundField DataField="PRICE" HeaderText="PRICE" 
                                SortExpression="PRICE" ReadOnly="True" />
                            <asp:BoundField DataField="QUANTITY" HeaderText="QUANTITY" 
                                SortExpression="QUANTITY" />
                            <asp:BoundField DataField="STATUS" HeaderText="STATUS" 
                                SortExpression="STATUS" />
                            <asp:BoundField DataField="TIME" HeaderText="TIME" SortExpression="TIME" />
                            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                        </Columns>
                        <FooterStyle BackColor="#CCCC99" />
                        <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                        <RowStyle BackColor="#F7F7DE" />
                        <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                        <SortedAscendingCellStyle BackColor="#FBFBF2" />
                        <SortedAscendingHeaderStyle BackColor="#848384" />
                        <SortedDescendingCellStyle BackColor="#EAEAD3" />
                        <SortedDescendingHeaderStyle BackColor="#575357" />
                    </asp:GridView> 

                    <asp:GridView ID="GridView" runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" 
                        DataKeyNames="IDMEMBER,IDPRODUCT" 
                        DataSourceID="LinqDataSourceOrders" CellPadding="4" ForeColor="Black" 
                        GridLines="Vertical" BackColor="White" BorderColor="#DEDFDE" 
                        BorderStyle="None" BorderWidth="1px">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:TemplateField HeaderText="Username" SortExpression="MEMBER.USERNAME">
                                <ItemTemplate>
                                    <%#Eval("MEMBER.USERNAME")%>
                                </ItemTemplate>
                            </asp:TemplateField>    
                            <asp:BoundField DataField="IDPRODUCT" HeaderText="IDPRODUCT" 
                                SortExpression="IDPRODUCT" ReadOnly="True" />
                            <asp:BoundField DataField="PRICE" HeaderText="PRICE" 
                                SortExpression="PRICE" />
                            <asp:BoundField DataField="QUANTITY" HeaderText="QUANTITY" 
                                SortExpression="QUANTITY" />
                            <asp:BoundField DataField="STATUS" HeaderText="STATUS" 
                                SortExpression="STATUS" />
                            <asp:BoundField DataField="TIME" HeaderText="TIME" SortExpression="TIME" />
                        </Columns>
                        <FooterStyle BackColor="#CCCC99" />
                        <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                        <RowStyle BackColor="#F7F7DE" />
                        <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                        <SortedAscendingCellStyle BackColor="#FBFBF2" />
                        <SortedAscendingHeaderStyle BackColor="#848384" />
                        <SortedDescendingCellStyle BackColor="#EAEAD3" />
                        <SortedDescendingHeaderStyle BackColor="#575357" />
                    </asp:GridView>
                        
                <asp:ImageButton ID="ButtonReset" runat="server" AlternateText="Reset" 
                        ImageUrl="~/images/button_reset.jpg" onclick="ButtonReset_Click" />
                <asp:LinqDataSource ID="LinqDataSourceOrders" runat="server" 
                        ContextTypeName="DTO.DataClassesNHOMMUADataContext" EntityTypeName="" 
                        TableName="ORDERs" Where="STATUS &gt;= @STATUS &amp;&amp; STATUS &lt;= @STATUS1" 
                        EnableDelete="True" EnableInsert="True" EnableUpdate="True">
                    <WhereParameters>
                        <asp:Parameter DefaultValue="0" Name="STATUS" Type="Int16" />
                        <asp:Parameter DefaultValue="1" Name="STATUS1" Type="Int16" />
                    </WhereParameters>
                </asp:LinqDataSource>

                    <%--Linq DataSource hiển thị các Orders có status 0 và 1--%>
                <asp:LinqDataSource ID="LinqDataSourceOrdersByStatus" runat="server" 
                        ContextTypeName="DTO.DataClassesNHOMMUADataContext" EntityTypeName="" 
                        TableName="ORDERs" EnableDelete="True" EnableInsert="True" 
                        EnableUpdate="True" Where="STATUS == @STATUS">
                    <WhereParameters>
                        <asp:ControlParameter ControlID="FilterByStatus" DefaultValue="0" Name="STATUS" 
                            PropertyName="SelectedValue" Type="Int16" />
                    </WhereParameters>
                </asp:LinqDataSource>

                <asp:LinqDataSource ID="LinqDataSourceOrdersByProduct" runat="server" 
                    ContextTypeName="DTO.DataClassesNHOMMUADataContext" EntityTypeName="" 
                    TableName="ORDERs" EnableDelete="True" EnableInsert="True" 
                    EnableUpdate="True" Where="IDPRODUCT == @IDPRODUCT">
                    <WhereParameters>
                        <asp:ControlParameter ControlID="FilterByProduct" DefaultValue="0" 
                            Name="IDPRODUCT" PropertyName="SelectedValue" Type="Int32" />
                    </WhereParameters>
                </asp:LinqDataSource>
                </div>        
            </div>
            <div class="tail">
                
            </div>
        </div>
        
    </div>    
</asp:Content>
